﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HuiWu.aspx.cs" Inherits="ZX.WebApp.Crm.HuiWu" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/calendar/assets/skins/sam/calendar.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/calendar/calendar-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
    <script src="../../Scripts/extend.validate.js" type="text/javascript"></script>
    <link href="../../Styles/base.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .box-radio
        {
            float:left;
            width: 800px;
            margin: 5px auto;
        }
        .slideul
        {
            width: 100%;
            float: left;
            padding: 2px 0px 2px 0px;
        }
        .slideul li
        {
            float:left;
            display: inline;
            margin-left: 50px;
        }
        .li2
        {
            padding-left:10px;
        }
        
        .boxpic
        {
            width: 100%;
            float: left;
        }
        .boxpic .imagePic
        {
            float: left;
            padding: 2px;
            border: 1px solid #ccc;
            margin-right: 2px;
            cursor: pointer;
        }
        .boxpic .on
        {
            border: 1px solid #f00;
        }
    </style>
</head>
<body class="yui-skin-sam" onkeydown="PreventBSK()">
    <form id="form1" runat="server">
    <div class="noprint">
        <div id="content">
            <h3>
                学员胸卡打印</h3>
            <table class="table2">
                <tr>
                    <th style="width: 15%;">
                        <span style="color: Red;">*</span><span>打印类型</span>
                    </th>
                    <td colspan="4">
                        <select style="width: 20%;" id="PrintType">
                            <option value="1">默认打印</option>
                            <option value="2">自定义打印</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red;">*</span><span>图片类型</span>
                    </th>
                    <td colspan="4">
                        <div class="box-radio">
                            <ul class="slideul">
                                <li>
                                    <input type="radio" name="imageRadio" id="image0" checked="checked" />执模图片</li>
                                <li class="li2">
                                    <input type="radio" name="imageRadio" id="image1" />战模图片</li>
                                <li class="li2">
                                    <input type="radio" name="imageRadio" id="image2" />助教/辅导员</li>
                                <li class="li2">
                                    <input type="radio" name="imageRadio" id="image3" />复训图片</li>
                            </ul>
                            <div class="boxpic">
                                <div class="imagePic">
                                    <img src="../../Images/zhimo1.jpg" width="130" height="150" /></div>
                                <div class="imagePic">
                                    <img src="../../Images/zhanmo1.png" width="130" height="150" /></div>
                                <div class="imagePic">
                                    <img src="../../Images/zhujiao1.jpg" width="130" height="150" /></div>
                                <div class="imagePic">
                                    <img src="../../Images/zfuxun1.jpg" width="130" height="150" /></div>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr class="t1">
                    <th>
                        <span style="color: Red;">*</span><span>文字标题</span>
                    </th>
                    <td colspan="4">
                        <input type="text" id="txtName" style="width: 19%;" />
                    </td>
                </tr>
                <tr class="t1">
                    <th>
                        <span style="color: Red;">*</span><span>时间标题</span>
                    </th>
                    <td colspan="4">
                        <input type="text" id="txtTime" style="width: 19%;" />
                    </td>
                </tr>
                <tr id="tr1">
                    <th>
                        <span style="color: Red;">*</span><span>课程规划期数</span>
                    </th>
                    <td colspan="4">
                        <input type="hidden" id="ProductLayoutID" runat="server" />
                        <input type="text" runat="server" id="txtProductLayoutID" readonly="readonly" style="width: 19%;" />
                        <button id="btnProductLayoutID" name="PP" type="button" class="btnCheck" style="height: 24px;">
                            选择</button>
                    </td>
                </tr>
                <tr class="t2">
                    <th>
                        <span>团号</span>
                    </th>
                    <td>
                        <input type="text" id="txtGroupName" style="width: 45%;" />
                    </td>
                    <th>
                        <span>分公司</span>
                    </th>
                    <td>
                        <input type="text" id="txtDeptName" style="width: 45%;" />
                    </td>
                </tr>
                <tr class="_hiden" id="tr2">
                    <th>
                        <span>学员姓名</span>
                    </th>
                    <td>
                        <input type="text" id="name1" class="width60" />
                    </td>
                    <th>
                        <span>团号/(助教、辅导员)</span>
                    </th>
                    <td>
                        <input type="text" id="group1" class="width10" />
                        <input type="button" value="删除行" class="btnDel" style="width: 50px;" />
                        <span>打印学员输入团号 / 打印助教、辅导员直接输入文字</span>
                    </td>
                </tr>
            </table>
            <table class="table1">
                <tr>
                    <th style="width: 15%;">
                        <input id="btnAddRow" type="button" value="添加行" class="btnCheck" style="width: 50px;
                            display: none;" />
                    </th>
                    <td colspan="3">
                        <input type="button" value="确定" class="btnCheck" style="width: 50px;" onclick="return PrintView()" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            信息选择</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    </form>
</body>
<script type="text/javascript">
    var count = 2;
    var radioValue = "1", userid = "<%=UserID %>";
    $(document).ready(function () {
        $("#tr2").hide();
        $("#PrintType").change(function () {
            if ($(this).val() == "1") {  //默认打印
                if (radioValue == "1" || radioValue == "2") {
                    $("#tr1").show();
                    $("#btnAddRow").hide();
                    $("._hiden").hide();
                    $("#tr2").hide();
                    $(".t1").show();
                    $(".t2").show();
                } else { //助教、辅导员
                    $(".t1").hide();
                    $(".t2").hide();
                }
            } else {
                if (radioValue == "1" || radioValue == "2") {
                    $("#tr1").hide();
                    $(".t2").hide();
                    $("#btnAddRow").show();
                    $("._hiden").hide();
                    $("#tr2").show();
                    $(".t1").show();
                    $.each($("._hiden"), function (i) {
                        $($(this).children().find("input")[0]).val("");
                        $($(this).children().find("input")[1]).val("");
                    });
                } else { //助教、辅导员
                    $(".t1").hide();
                    $(".t2").hide();
                }
            }
        })
        $("#btnAddRow").click(function () {
            if (count > 9) {
                alert("自定义打印最大数量为10!");
                return;
            } else {
                count = $("._hiden").length + 1;
                var html = "<tr class=\"_hiden\">" +
                                "    <th><span>学员姓名</span></th>" +
                                "    <td>" +
                                "        <input type=\"text\" class=\"width60\" />" +
                                "    </td>" +
                                "    <th><span>团号/(助教、辅导员)</span></th>" +
                                "    <td>" +
                                "        <input type=\"text\" class=\"width10\" />" +
                                "        <input type=\"button\" value=\"删除行\" class=\"btnDel\" style=\"width: 50px;\" />" +
                                "        <span>打印学员输入团号，打印助教、辅导员请直接输入文字</span>" +
                                "    </td>" +
                                "</tr>";
                var tempHtml = html;
                $(".table2").append(tempHtml);
            }
        });
        $(".btnDel").live("click", function () {
            $(this).parent().parent().remove();
            count = $("._hiden").length - 1;
        });

        $(".imagePic").each(function (i) {
            $(this).click(function () {
                $(this).siblings().removeClass("on");
                $(this).addClass("on");
                $('#image' + i).attr("checked", 'checked');
                if (i == 0 || i == 3) {
                    if (i == 0) {
                        radioValue = "1";
                    } else if (i == 3) {
                        radioValue = "4";
                    }
                    if ($("#PrintType").val() == "1") {  //默认
                        $("#tr1").show();
                        $("#btnAddRow").hide();
                        $("._hiden").hide();
                        $("#tr2").hide();
                        $(".t1").show();
                        $(".t2").show();
                    } else {
                        $("#tr1").hide();
                        $(".t2").hide();
                        $("#btnAddRow").show();
                        $("._hiden").hide();
                        $("#tr2").show();
                        $(".t1").show();
                        $.each($("._hiden"), function (i) {
                            $($(this).children().find("input")[0]).val("");
                            $($(this).children().find("input")[1]).val("");
                        });
                    }
                } else if (i == 1) {
                    radioValue = "2";
                    if ($("#PrintType").val() == "1") {  //默认
                        $("#tr1").show();
                        $("#btnAddRow").hide();
                        $("._hiden").hide();
                        $("#tr2").hide();
                        $(".t1").show();
                        $(".t2").show();
                    } else {
                        $("#tr1").hide();
                        $(".t2").hide();
                        $("#btnAddRow").show();
                        $("._hiden").hide();
                        $("#tr2").show();
                        $(".t1").show();
                        $.each($("._hiden"), function (i) {
                            $($(this).children().find("input")[0]).val("");
                            $($(this).children().find("input")[1]).val("");
                        });
                    }
                } else if (i == 2) {
                    radioValue = "3";
                    $("#tr1").hide();
                    $(".t2").hide();
                    $("#btnAddRow").show();
                    $("._hiden").hide();
                    $("#tr2").show();
                    $(".t1").show();
                    $.each($("._hiden"), function (i) {
                        $($(this).children().find("input")[0]).val("");
                        $($(this).children().find("input")[1]).val("");
                    });
                    $(".t1").hide();
                    $("#PrintType").get(0).selectedIndex = 1;
                }
            })
        });
        $("input[name=imageRadio]").click(function () {
            $(".imagePic:eq(" + $(this).index("input[name=imageRadio]") + ")").click();
        });
    });
    function PrintView() {
        var PrintType = $("#PrintType").val();
        var LayoutName = $("#txtName").val();
        var ProductLayoutTime = $("#txtTime").val();
        var ProductLayoutID = $("#ProductLayoutID").val();
        var vGroupName = "";
        var vDeptName = "";
        var StudentList = "";
        if (radioValue == "3") { //打印助教和辅导员
            if (PrintType == "1") { //自定义打印
                alert("您选择的图片类型将打印助教或者辅导员,请选择自定义打印类型!");
                return;
            }
        } else {
            if (LayoutName == "") {
                alert("请输入文字标题!");
                $("#txtName").focus();
                return;
            }
            if (ProductLayoutTime == "") {
                alert("请输入时间标题!");
                $("#txtTime").focus();
                return;
            }
        }
        if (PrintType == "2") { //自定义打印
            var Alist = [], groupList = [];
            $.each($("._hiden"), function (i) {
                var name = $($(this).children().find("input")[0]).val();
                var group = $($(this).children().find("input")[1]).val();
                groupList.push(group);
                var result = name + "$" + group;
                Alist.push(result);
            });
            StudentList = Alist.join("@");
        } else {
            vGroupName = $("#txtGroupName").val();
            vDeptName = $("#txtDeptName").val();
            if (ProductLayoutID == "") {
                alert("请选择课程规划期数!");
                $("#txtProductLayoutID").focus();
                return;
            }
        }
        window.open("StudentPrint.aspx?id=" + ProductLayoutID + "&printType=" + PrintType + "&imgType=" + radioValue +
                    "&layoutName=" + encodeURI(LayoutName) + "&layoutTime=" + encodeURI(ProductLayoutTime) +
                    "&json=" + encodeURI(StudentList) + "&groupName=" + vGroupName + "&deptName=" + encodeURI(vDeptName));
    }

    /* 对应的方法和ID*/
    var _fn, _id;
    function ShowDialog(fn, id, src) {
        _fn = fn;
        _id = id;
        document.getElementById("EditUIWindow1").src = src;
        YAHOO.example.container.dialog1.show();
    }
    YAHOO.namespace("example.container");
    YAHOO.util.Event.onDOMReady(function () {
        var handleSubmit = function () {
            var editwindow = document.getElementById("EditUIWindow1");
            if (editwindow) {
                editwindow.contentWindow.ChooseInfo();
            }
            YAHOO.example.container.dialog1.hide();
        };
        var handleCancel = function () {
            this.cancel();
        };
        var handleSuccess = function (o) {
            var response = o.responseText;
            response = response.split("<!")[0];
            document.getElementById("resp").innerHTML = response;
        };
        var handleFailure = function (o) {
            alert("Submission failed: " + o.status);
        };
        YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					        { width: "650px",
					            height: "450px",
					            fixedcenter: true,
					            visible: false,
					            draggable: true,
					            close: true,
                                modal:true,
					            autofillheight: "body",
					            constraintoviewport: true,
					            buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								        { text: "取消", handler: handleCancel}]
					        });
        YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
        YAHOO.example.container.dialog1.render();
        //拖动大小1
        var resize = new YAHOO.util.Resize("dialog1", {
            handles: ["br"],
            autoRatio: false,
            minWidth: 450,
            minHeight: 300,
            status: false
        });
        resize.on("startResize", function (args) {
            if (this.cfg.getProperty("constraintoviewport")) {
                var D = YAHOO.util.Dom;

                var clientRegion = D.getClientRegion();
                var elRegion = D.getRegion(this.element);

                resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
                resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
            } else {
                resize.set("maxWidth", null);
                resize.set("maxHeight", null);
            }

        }, YAHOO.example.container.dialog1, true);
        resize.on("resize", function (args) {
            var panelHeight = args.height;
            this.cfg.setProperty("height", panelHeight + "px");
        }, YAHOO.example.container.dialog1, true);
    });
</script>
</html>
